package com.softer.wxzj.common.entity;

import com.softer.wxzj.common.enums.MessageEnum;
import com.softer.wxzj.common.enums.ShiroResultEnum;
import lombok.Data;

/**
 * @author zcz
 * @date 2019/1/16
 */
@Data
public class CommonResult {
    /**
     * 状态码
     */
    private Integer data;
    /**
     * 状态信息
     */
    private String message;


    public CommonResult(Integer data, String message) {
        this.data = data;
        this.message = message;
    }

    /**
     * CURD操作时使用，返回是否操作成功
     * @param i
     * @return
     */
    public static CommonResult ResponseResult(int i){
        if(i>0){
            return new CommonResult(ShiroResultEnum.SUCCESS.getCode(), MessageEnum.SUCCESS.getMsg());
        }
        return new CommonResult(ShiroResultEnum.FAIL.getCode(), MessageEnum.FAIL.getMsg());
    }
}
